@echo off
echo "==>TAO_ROOT=%TAO_ROOT%"

set PROJECT_PATH="%TAO_ROOT%/orbsvcs/tests/FT_App"

cd %PROJECT_PATH%


@echo off
setlocal

:: 定义要删除的文件列表
set "files=*.ior"

:: 删除文件
for %%f in (%files%) do (
    if exist "%%f" (
        echo Deleting %%f...
        del "%%f"
        if not errorlevel 1 (
            echo Deleted %%f successfully.
        ) else (
            echo Error deleting %%f.
        )
    ) else (
        echo %%f does not exist. Skipping.
    )
)


echo "==>Start ft_replica1"
start "ft_replica1" cmd /k "ft_replica -o %PROJECT_PATH%/factory1.ior -f none -t %PROJECT_PATH%/replica1.ior -l loc1 -i type1 -q -p %PROJECT_PATH%/persistent.dat"
timeout /t 4

echo "==>Start ft_replica2"
start "ft_replica2" cmd /k "ft_replica -o %PROJECT_PATH%/factory2.ior -f none -t %PROJECT_PATH%/replica2.ior -l loc2 -i type1 -q -p %PROJECT_PATH%/persistent.dat" 
timeout /t 4


echo "==>Start tao_fault_detector"
start "tao_fault_detector" cmd /k "%TAO_ROOT%/orbsvcs/Fault_Detector/tao_fault_detector -r -o %PROJECT_PATH%/detector.ior -q"
timeout /t 10

echo "==>Start tao_fault_notifier"
start "tao_fault_notifier" cmd /k "%TAO_ROOT%/orbsvcs/Fault_Notifier/tao_fault_notifier -r -o %PROJECT_PATH%/notifier.ior -q"
timeout /t 5

@REM 与3 不同的是 使用故障消费者 代替 故障分析器
echo "==>Start ft_fault_consumer"
start "ft_fault_consumer" cmd /k "ft_fault_consumer -o %PROJECT_PATH%/ready.file -n file://%PROJECT_PATH%/notifier.ior -d file://%PROJECT_PATH%/detector.ior -r file://%PROJECT_PATH%/replica1.ior -r file://%PROJECT_PATH%/replica2.ior -q"
timeout /t 15

echo "==>Start ft_client"
start "ft_client" cmd /k "ft_client -f file://%PROJECT_PATH%/replica1.ior -f file://%PROJECT_PATH%/replica2.ior -c testscript"

@echo off


@REM  故障消费者 
@REM start ./ft_replica -o %PROJECT_PATH%/factory1.ior -f none -t %PROJECT_PATH%/replica1.ior -l loc1 -i type1 -q -p %PROJECT_PATH%/persistent.dat
@REM start ./ft_replica -o %PROJECT_PATH%/factory2.ior -f none -t %PROJECT_PATH%/replica2.ior -l loc2 -i type1 -q -p %PROJECT_PATH%/persistent.dat
@REM start %TAO_ROOT%/orbsvcs/Fault_Detector/tao_fault_detector  -r -o %PROJECT_PATH%/detector.ior -q
@REM start %TAO_ROOT%/orbsvcs/Fault_Notifier/tao_fault_notifier -r -o %PROJECT_PATH%/notifier.ior -q
@REM start ./ft_fault_consumer -o %PROJECT_PATH%/ready.file -n file://consumer_notifier_ior -d file://%PROJECT_PATH%/detector.ior -r file://%PROJECT_PATH%/replica1.ior -r file://%PROJECT_PATH%/replica2.ior -q
@REM start ./ft_client -f file://%PROJECT_PATH%/replica1.ior -f file://%PROJECT_PATH%/replica2.ior -c testscript

@REM 原始命令
@REM start ./ft_replica -o E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\factory1.ior -f none -t E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\replica1.ior -l loc1 -i type1 -q -p E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\persistent.dat
@REM start ./ft_replica -o E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\factory2.ior -f none -t E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\replica2.ior -l loc2 -i type1 -q -p E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\persistent.dat
@REM start E:\_proj\_opendds\ACE_wrappers\TAO/orbsvcs/Fault_Detector/tao_fault_detector  -r -o E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\detector.ior -q
@REM start E:\_proj\_opendds\ACE_wrappers\TAO/orbsvcs/Fault_Notifier/tao_fault_notifier -r -o E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\notifier.ior -q
@REM start ./ft_fault_consumer -o E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\ready.file -n file://notifier.ior -d file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\detector.ior -r file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\replica1.ior -r file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\replica2.ior -q
@REM start ./ft_client -f file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\replica1.ior -f file://E:\_proj\_opendds\ACE_wrappers\TAO\orbsvcs\tests\FT_App\replica2.ior -c testscript